package cn.fzkj.project.system.controller;

import cn.fzkj.common.utils.ServletUtils;
import cn.fzkj.framework.security.service.TokenService;
import cn.fzkj.framework.web.domain.ResultVO;
import cn.fzkj.project.system.domain.SysSummary;
import cn.fzkj.project.system.service.ISysSummaryService;
import org.aspectj.lang.annotation.RequiredTypes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "summary")
public class SysSummaryController {

    @Autowired
    private ISysSummaryService summaryService;
    @Autowired
    private TokenService tokenService;

    /** 查询 */
    @RequestMapping(value = "list", method = RequestMethod.GET)
    public ResultVO list(SysSummary summary){
        return ResultVO.success(summaryService.selectList(summary));
    }

    /** 更新 */
    @RequestMapping(value = "edit", method = RequestMethod.POST)
    public ResultVO edit(@RequestBody SysSummary summary){
        return ResultVO.success(summaryService.updateSummary(summary));
    }

    /** 新增 */
    @RequestMapping(value = "insert", method = RequestMethod.POST)
    public ResultVO insert(@RequestBody SysSummary summary){
        return ResultVO.success(summaryService.insertSummary(summary));
    }

    /** 查询主动些 */
    @RequestMapping(value = "selectAuto", method = RequestMethod.GET)
    public ResultVO selectAuto (@RequestParam(value = "category", required = false) String category){
        Long userId = tokenService.getLoginUser(ServletUtils.getRequest()).getUser().getUserId();
        return ResultVO.success(summaryService.selectListAuto(category, userId));
    }

    /** 查询自动写 */
    @RequestMapping(value = "selectNotAuto", method = RequestMethod.GET)
    public ResultVO selectNotAuto (@RequestParam(value = "category", required = false) String category){
        Long userId = tokenService.getLoginUser(ServletUtils.getRequest()).getUser().getUserId();
        return ResultVO.success(summaryService.selectListNotAuto(category, userId));
    }
}
